package com.dailyblue.java.project.power.controller;

import com.alibaba.fastjson.JSONArray;
import com.dailyblue.java.project.power.service.PowersService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/powers")
public class PowersController {
    @Resource
    private PowersService powersService;

    @GetMapping("/execute")
    public String execute() {
        return JSONArray.toJSONString(powersService.findAllPower());
    }

    @GetMapping(value = "/uid", produces = {"application/json;charset=utf-8"})
    public String findByUserId(int uid) {
        return JSONArray.toJSONString(powersService.findPowerByUserId(uid));
    }
}
